﻿using ExpenseSystem.Common;
using ExpenseSystem.Common.BaseModel;
using ExpenseSystem.Core.Authority;
using ExpenseSystem.Core.Converter;
using ExpenseSystem.Core.DataAddOn;
using ExpenseSystem.Core.ProductionModules;
using ExpenseSystem.Fether;
using ExpenseSystem.Model;
using System.Web.Http;
namespace ExpenseSystem.Controllers
{
    [RoutePrefix("api/Production")]
    public class ProductionController : ApiController
    {
        SetInhibition setInhibition;
        GetInhibition getInhibition;
        SetInhibitionMaker inhibitionMaker = new StateInhibitionMaker();
        GetInhibitionMaker getInhibitionMaker = new GetInhibitionMaker();
        public ProductionController()
        {
            setInhibition = inhibitionMaker.Make();
            getInhibition = getInhibitionMaker.Make();
        }

        ProductionFetcher fetcher = new ProductionFetcher();
        ProductionManager manager = ProductionManager.CreateInstance();
        ProductionTypeFetcher tfetcher = new ProductionTypeFetcher();
        ProductionTypeManager tmanager = new ProductionTypeManager();
        [Route("List")]
        [HttpGet]
        public ResponseModel List([FromUri]RequestArgs paramModels)
        {
            return NormalControllerHelper.List(fetcher, "BAS_PRODUCTION_LIST", paramModels, getInhibition);
        }
        [Route("Export")]
        [HttpGet]
        public ResponseModel Export([FromUri]RequestArgs paramModels)
        {
            ExpFetcher<ProductionExp> fetcher = new ExpFetcher<ProductionExp>();
            return NormalControllerHelper.Export(fetcher, "BAS_PRODUCTION_LIST", RestainConverter.FromRequestArgs(paramModels));
        }
        [Route("Get")]
        [HttpGet]
        public ResponseModel Get(long id)
        {
            return NormalControllerHelper.Get(fetcher, "BAS_PRODUCTION_LIST", id, getInhibition);
        }
        [Route("Set")]
        [HttpPost]
        public ResponseModel Set(ProductionModel data)
        {
            return NormalControllerHelper.Set(fetcher, "BAS_PRODUCTION_SET", data, manager, setInhibition, getInhibition,new ProductionSetRateAddOn());
        }

        [Route("Remove")]
        [HttpPost]
        public ResponseModel Remove(ProductionModel data)
        {
            return NormalControllerHelper.Remove("BAS_PRODUCTION_DEL", data, manager);
        }

        [Route("RemoveById")]
        [HttpGet]
        public ResponseModel RemoveById([FromUri]long[] id)
        {
            return NormalControllerHelper.RemoveById("BAS_PRODUCTION_LIST", id, manager);
        }

        [Route("ListType")]
        [HttpGet]
        public ResponseModel ListType([FromUri]RequestArgs paramModels)
        {
            return NormalControllerHelper.List(tfetcher, "BAS_PRODUCTION_LIST", paramModels, getInhibition);
        }
        [Route("GetType")]
        [HttpGet]
        public ResponseModel GetType(long id)
        {
            return NormalControllerHelper.Get(tfetcher, "BAS_PRODUCTION_LIST", id, getInhibition);
        }

        [Route("SetType")]
        [HttpPost]
        public ResponseModel SetType(ProductionTypeModel data)
        {
            return NormalControllerHelper.Set(tfetcher, "BAS_PRODUCTION_SET", data, tmanager, setInhibition, getInhibition);
        }

        [Route("RemoveType")]
        [HttpPost]
        public ResponseModel RemoveType(ProductionTypeModel data)
        {
            return NormalControllerHelper.Remove("BAS_PRODUCTION_DEL", data, tmanager);
        }

        [Route("RemoveTypeById")]
        [HttpGet]
        public ResponseModel RemoveTypeById([FromUri]long[] id)
        {
            return NormalControllerHelper.RemoveById("BAS_PRODUCTION_LIST", id, tmanager);
        }
    }
}
